import MySQLdb

try:
    conn = MySQLdb.connect(
        host='localhost',
        user='zlq',
        password='zlq20000612.',
        database='django_db',
        port=3306,
        charset='utf8mb4'
    )
    print("连接成功！")
    conn.close()
except Exception as e:
    print(f"连接失败: {e}")